﻿using System;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using HelixToolkit.Wpf;

namespace GameBoard
{
    public class MaterialMaker
    {
        public static ImageBrush MakeImageMaterial(String imageLocation)
        {
            var imageBrush = new ImageBrush();
            imageBrush.ImageSource =
                new BitmapImage(
                    new Uri(imageLocation, UriKind.Relative)
                    );

            return imageBrush;
        }

        public static Material PaperbackMaterial()
        {
            var expected = GameboardConstants.MapPictureDirectory + "\\" + GameboardConstants.BackgroundName;
            if (File.Exists(expected))
            {
                return new DiffuseMaterial(MakeImageMaterial(expected));
            }
            return DefaultBackMaterial;
        }

        public static Material DefaultFrontMaterial
        {
            get { return Materials.Green; }
        }

        private static Material DefaultBackMaterial
        {
            get { return Materials.LightGray; }
        }

        internal static Material MaterialFromColor(Color thecolor)
        {
            return new DiffuseMaterial(new SolidColorBrush(thecolor));
        }
    }
}